
layui.use(['form','table'],function(){


    $ = layui.jquery;
    var form = layui.form,
        table = layui.table;



   /* //用户列表
    var tableIns=table.render({
        elem: '#scaleInfo',
        url : '/sharepark/scale/list',
        cellMinWidth : 95,
        height : 79,
        id : "logList",
        cols : [[
            {field: 'sRent', title: '出租方', width:150, marginLeft:300, align:'center'},
            {field: 'sCommunity', title: '物业方', width:150, align:'center'},
            {field: 'sSystem', title: '平台方', align:'center',width:150},
        ]]
    });*/

    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data) {

            $.ajax({
                url:"/sharepark/scale/update",
                type:"post",
                data:data.field,
                success:function (result) {
                    if (result.msg =="配置成功"){
                        //tableIns.reload();
                        window.location.reload();
                        document.getElementById("fm").reset();
                        layer.msg("配置成功");
                    }
                    else {
                        layer.msg(result.msg, {time: 2000});
                    }
                }
            });
            return false;
        });
    });

})

// 基于准备好的dom，初始化echarts实例

    $(function () {
        getData4();
    });
    function  getData4() {
        $.ajax({
            type: 'post',
            dataType: 'text',
            url:  '/sharepark/scale/circle',
            data: {},
            cache: false,
            async: true,
            success: function (data) {
                var data = eval('(' + data + ')');
                var data1 = new Array();
                for(var i=0; i < data.mapName.length; i++){
                    data1[i] = {value:data.mapValue[i],name:data.mapName[i]}
                }
                //alert(JSON.stringify(data));
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                option = {
                    title : {
                        text: '三方抽成比例图',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data: data1
                    },
                    series : [
                        {
                            name: '抽成比例',
                            type: 'pie',
                            radius : '55%',
                            center: ['50%', '60%'],
                            data:data1,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                },
                                normal:{
                                    label:{
                                        show: true,
                                        formatter: '{b} : {d}%'
                                    },
                                    labelLine :{show:true}
                                }
                            }
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        });
    }
